package org.funny.machine32.hardware.common;

import com.google.common.collect.Maps;
import org.funny.machine32.hardware.processors.cpu.CpuRegisterFile;

import java.util.Map;

public enum HardwareComponentEnum {
    CPU("CPU"),
    ALU("ALU"),
    MainMemory("MainMemory"),
    GPU("GPU"),
    DISK("DISK"),
    BUS("BUS"),
    REGISTER("REGISTER"),
    CPU_REGISTER_FILE("CPU_REGISTER_FILE"),
    R_FLAG("R_FLAG"),
    R_PC("R_PC"),
    R_MD("R_MD"),
    R_MA("R_MA"),
    R_IR("R_IR"),
    R_C("R_C"),
    R_A("R_A"),
    ;

    private String name;

    private HardwareComponentEnum(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static String getComponentName(Class clazz) {
        return map.get(clazz);
    }

    private static Map<Class, String> map = init();
    private static Map<Class, String> init() {
        Map<Class, String> map = Maps.newHashMap();
        map.put(CpuRegisterFile.class, CPU_REGISTER_FILE.getName());

        return map;
    }
}
